package com.utils;

import com.model.BackUser;
import com.model.FrontUser;
import org.springframework.util.DigestUtils;

import java.time.LocalDate;

public class Md5Utils {

    public static String decodeBackUser(BackUser user) {
        return Md5Utils.decode(user.getUsername() + "/" + user.getPassword());
    }

    public static String decodeBackUser(FrontUser user) {
        return Md5Utils.decode(user.getUsername() + "/" + user.getPassword());
    }

    public static String decode(String str) {
        return DigestUtils.md5DigestAsHex(str.getBytes());
    }

    public static void main(String[] args) throws InterruptedException {
        StringBuilder sb = new StringBuilder("HHH");
        ThreadLocal<String> threadLocal = new ThreadLocal<>();
        new Thread(() -> {
            threadLocal.set("ss");
        }).start();
        Thread.sleep(1000);
        new Thread(() -> {
            System.out.println(threadLocal.get());
        }).start();
    }

}
